<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="x-rim-auto-match" content="none">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <title>初融共盈</title>
    <link rel="stylesheet" href="../../css/contrive.css">
    <script type="text/javascript" src="/js/assets/jquery-3.1.0.min.js"></script>
    <script type="text/javascript" src="/js/htmlfive/rootfont.js"></script>
    <script type="text/javascript" src="/js/layer/layer.js"></script>
    <!--<script type="text/javascript" src="/js/htmlfive/contrive.js"></script>-->
    <script type="text/javascript">
        (function(root) {
            root._tt_config = true;
            var ta = document.createElement('script'); ta.type = 'text/javascript'; ta.async = true;
            ta.src = document.location.protocol + '//' + 's3.pstatp.com/bytecom/resource/track_log/src/toutiao-track-log.js';
            ta.onerror = function () {
                var request = new XMLHttpRequest();
                var web_url = window.encodeURIComponent(window.location.href);
                var js_url  = ta.src;
                var url = '//ad.toutiao.com/link_monitor/cdn_failed?web_url=' + web_url + '&js_url=' + js_url + '&convert_id=65773188063';
                request.open('GET', url, true);
                request.send(null);
            }
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ta, s);
        })(window);
    </script>
</head>
<body>
<div class="register_first_bg">
    <input class="register_first_input" id="mobile" type="phone" placeholder="请输入手机号码" maxlength="11" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
    <div type="submit" class="register_first_btn"></div>
</div>
<div class="register_bg" hidden>
    <input class="phone_input" id="phone" type="text" disabled>
    <input class="imgcode_input" type="text" placeholder="图片验证码" maxlength="4" id="code">
    <div class="imgcode_btn">
        <img class="validImg" src="/sys/ImageServlet" style="width: 100%"/>
    </div>
    <input class="code_input" id="mobileCode" type="text" placeholder="手机验证码" maxlength="4">
    <div class="code_btn">
        获取验证码
    </div>
    <input class="passwrod_input" id="password" type="password" placeholder="密码为6-20位数字或字母" maxlength="20">
    <div type="submit" class="register_btn"></div>
</div>
<div class="register_end_bg" hidden>
    <div type="submit" class="register_end_btn"></div>
</div>
<script type="text/javascript">
    $(window).ready(function(){
        //获取屏幕高度，全屏显示
        var winHei = $(window).height();
        var winWidth = $(window).width();
        $(".register_bg").height(winHei);
        $(".register_first_bg").height(winWidth*2127/640);
        $(".register_end_bg").height(winHei);

        function Trim(str,is_global)
        {
            var result;
            result = str.replace(/(^\s+)|(\s+$)/g,"");
            if(is_global.toLowerCase()=="g")
            {
                result = result.replace(/\s/g,"");
            }
            return result;
        }
        $('.validImg').click(function() {
            $(".validImg").prop("src", "/sys/ImageServlet?time=" + new Date());
        });
        var href=Trim(decodeURI(window.location.href),'g');
        var source='';
        if(href.indexOf('source')!=-1){
            source=href.split('source=')[1].split('?')[0];
        }
        function getMsg(){
            var phone=$('#phone').val();
            var validNum=$("#code").val();
            if(phone==""){
                layer.tips("请先输入手机号",'#phone');
                return;
            }
            if (!/^[1][3,4,5,7,8][0-9]{9}$/.exec(phone)) {
                layer.tips("请输入正确的手机号",'#phone');
                return;
            }
            if(validNum==""){
                layer.tips("请先输入验证码",'#code');
                return;
            }
            var that=$('.code_btn');
            time(that);

            //短信接口
            $.ajax({
                type: "POST",
                url: "/registerSendSms",
                data: {
                    mobile:phone,
                    pictureCode: validNum
                },
                dataType: "json",
                success: function (data) {
                    if(data.result=='success'){
                        layer.msg("短信已发送！");
                    }else{
                        wait=0;
                        layer.msg(data.messageText);
                    }
                }
            });
        };
        $(".code_btn").bind("click", function () {
            getMsg();
        });
        var wait=60;
        function time(o) {
            if (wait == 0) {
                $(".code_btn").bind("click", function () {
                    getMsg();
                });
                o.html('获取验证码');
                wait = 60;
                $('.validImg').trigger('click')
            } else {
                $(".code_btn").unbind();
                o.html("重新发送(" + wait + "s)");
                wait--;
                setTimeout(function() {
                        time(o)
                    },
                    1000)
            }
        }
        $('.register_btn').bind('click',function(){
            var phone=$('#phone').val();
            var verification=$('#mobileCode').val();
            var validNum=$("#code").val();
            var peopleChoice = $('#people-choice').val();
            var password = $('#password').val();
            var invite = $('#invite').val();
            if(phone==""){
                layer.tips("请先输入11位手机号",'#phone');
                return;
            }
            if (!/^[1][3,4,5,7,8][0-9]{9}$/.exec(phone)) {
                layer.tips("请输入正确的手机号",'#phone');
                return;
            }
            if(validNum==""){
                layer.tips("请输入图片验证码",'#code');
                return;
            }
            if(verification==""){
                layer.tips("请先输入验证码",'#mobileCode');
                return;
            }
            if(password==""){
                layer.tips("请先设置密码",'#password');
                return;
            }
            if(password.length<6){
                layer.tips("密码格式不正确",'#password');
                return;
            }
            //图片验证
            //图片验证码
            $('.validImg').click(function() {
                $(".validImg").attr("src", "/sys/ImageServlet?time=" + new Date());
            });
            layer.load();
            $.ajax({
                type: "POST",
                url: "/register/pcRegister",
                data: {
                    mobile:phone,
                    mobileCode:verification,
                    pictureCode: validNum,
                    invite:invite,
                    password:password,
                    source:source
                },
                dataType: "json",
                success: function (data) {
                    if(data.result=='success'){
                        $(".register_bg").hide();
                        $(".register_end_bg").show();
                        _taq.push({convert_id:"65773188063", event_type:"form"});
                    }else{
                        layer.msg(data.messageText);
                    }
                    setTimeout(function(){
                        layer.closeAll('loading');
                    }, 2000);
                }
            });

        });
        $(".register_first_btn").bind("click", function () {
            var mobile=$('#mobile').val();
            if(mobile==""){
                layer.tips("请先输入11位手机号",'#mobile');
                return;
            }
            if (!/^[1][3,4,5,7,8][0-9]{9}$/.exec(mobile)) {
                layer.tips("请输入正确的手机号",'#mobile');
                return;
            }
            $(".register_first_bg").hide();
            $('body').css("overflow","hidden");
            $(".register_bg").show();
            $("#phone").val(mobile);

        });
        $(".register_end_btn").bind("click",function(){
            window.location.href="/index?0?0";
        });
    })
</script>
</body>
</html>
